/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Yahtzee;

/**
 *
 * @author agreseth
 */
import java.io.*;
import java.net.*;

public class Client {

    Socket echoSocket;
    PrintWriter out;
    BufferedReader in;
    BufferedReader stdIn;
    ServerGUI gui;

public Client()
{
        Socket echoSocket = null;
        PrintWriter out = null;
        BufferedReader in = null;
}
public void start(String ip, int port, ServerGUI gu)
{
    gui = gu;
        try {
            echoSocket = new Socket(ip, port);
            out = new PrintWriter(echoSocket.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(
                                        echoSocket.getInputStream()));
            
            gui.messagesTextArea.setText(in.readLine());
            out.println("Final Score 2999 <end>");
        } catch (UnknownHostException e) {
            System.err.println("Don't know about host: taranis.");
            System.exit(1);
        } catch (IOException e) {
            System.err.println("Couldn't get I/O for "
                               + "the connection to: taranis.");
            System.exit(1);
        }

        // get info from server, output to screen
        try{
        String fromServer = in.readLine();
        System.out.println(fromServer);
        }
        catch(Exception e)
        {
            
        }
  
        
	stdIn = new BufferedReader(new InputStreamReader(System.in));
	String userInput;

//	while ((userInput = stdIn.readLine()) != null) {
//	    out.println(userInput);
//	    System.out.println("echo: " + in.readLine());

//	}
        try
        {
            String fromServer = in.readLine();
            System.out.println("This is legit");
            System.out.println(fromServer);
        }
        catch (Exception e)
        {
            System.out.println("Problem reading input!");
        }
}
        public void close()
        {
            try
            {

                out.close();
                in.close();
                stdIn.close();
                echoSocket.close();
            }
            catch (Exception e)
            {
                System.out.println("Client closing failed!");
            }
        }

}



